/**
 * Created by sxh on 2018/4/18.
 */
define(['jquery', 'angular', 'app.services', 'require'],function($, angular, services,  require){
    'use strict';

    services.service('xddService', ['$resource','Base','$q',function ($resource,Base,$q) {
        /*--------------------------------------商品------------------------*/
        //获取商品列表信息
        this.getGoodsList = function (pageIndex,pageSize,goodsParam,success,error) {
            return $resource(Base.stringFormat("/api/goods/getList/:pageIndex/:pageSize"),{pageIndex:pageIndex,pageSize:pageSize}).save(goodsParam,success,error);
        };
        //上/下架商品
        this.updateStatus=function (goodsId,status,success,error) {
            return $resource(Base.stringFormat("/api/goods/updateStatus/:goodsId/:status"),{goodsId:goodsId,status:status}).get(success,error);
        };
        //审核商品
        this.goodsCheckStatus=function (goodsId,checkStatus,success,error) {
            return $resource(Base.stringFormat("/api/goods/checkStatus/:goodsId/:checkStatus"),{goodsId:goodsId,checkStatus:checkStatus}).get(success,error);
        };
        //添加商品
        this.addGoods=function (goods,success,error) {
            return $resource(Base.stringFormat("/api/goods/add")).save(goods,success,error);
        };
        //添加商品轮播图片
        this.addGoodsPic=function (param,success,error) {
            return $resource(Base.stringFormat("/api/goods/addGoodsPic")).save(param,success,error);
        };
        //删除商品
        this.deleteGoods=function (goodsId,success,error) {
            return $resource(Base.stringFormat("/api/goods/delete/:goodsId"),{goodsId:goodsId}).delete(success,error);
        };
        //根据ID删除评价信息内容
        this.deleteEvaluate=function(id,success,error){
            return $resource(Base.stringFormat("/api/evaluate/delete/:id"),{id:id}).delete(success,error);
        }
        //删除展示图片
        this.deleteIconUrl=function(id,success,error){
            return $resource(Base.stringFormat("/api/goods/updateIconUrl/:id"),{id:id}).get(success,error);
        };
        //删除轮播图片
        this.deletePic=function(goodsId,id,picUrl,success,error){
            return $resource(Base.stringFormat("/api/goods/deleteImage/:goodsId/:id?url=:picUrl"),{goodsId:goodsId,id:id,picUrl:picUrl}).get(success,error);
        }
        //修改展示图片
        this.updateIconUrl=function (param,success,error) {
            return $resource(Base.stringFormat("/api/goods/updateIconUrl")).save(param,success,error);
        };
        //修改商品信息
        this.updateGoods = function (goods,success,error) {
            return $resource(Base.stringFormat("/api/goods/update"), null, {'save': {method: 'PUT'}}).save(goods,success, error);
        };
        //获取商品类型列表
        this.getGType=function (type,success,error) {
            return $resource(Base.stringFormat("/api/gType/GTypelist/:type"),{type:type}).get(success,error);
        }
        //获取商品样式列表
        this.getGStyle=function (success,error) {
            return $resource(Base.stringFormat("/api/gStyle/getGStyleList")).get(success,error);
        }

        //获取商品一级分类
        this.getTypeOne=function (success,error) {
            return $resource(Base.stringFormat("/api/gTypeOne/getTypeOne")).get(success,error);
        }
        //获取商品下级
        this.getSecondType=function (pId,level,success,error) {
            return $resource(Base.stringFormat("/api/gTypeOne/getSecondType/:pId/:level"),{pId:pId,level:level}).get(success,error);
        }
        //根据商品直接获取二级三级属性
        this.getTypeAndStyle=function (type,gstyle,success,error) {
            return $resource(Base.stringFormat("/api/gTypeOne/getTypeAndStyle/:type/:gstyle"),{type:type,gstyle:gstyle}).get(success,error);
        }
        //根据商品直接获取二级属性
        this.getTypeByGoodType=function (type,success,error) {
            return $resource(Base.stringFormat("/api/gTypeOne/getTypeByGoodType/:type"),{type:type}).get(success,error);
        }
        //根据商品直接获取三级属性
        this.getStyleByGoodStyle=function (gstyle,success,error) {
            return $resource(Base.stringFormat("/api/gTypeOne/getStyleByGoodStyle/:gstyle"),{gstyle:gstyle}).get(success,error);
        }
        //根据goodsId获取商品信息
        this.getGoodsById=function (goodsId,success,error) {
            return $resource(Base.stringFormat("/api/goods/getGoodsById/:goodsId"),{goodsId:goodsId}).get(success,error);
        };
        //根据goodsId获取商品图片
        this.getGoodsPic=function (goodsId,success,error) {
            return $resource(Base.stringFormat("/api/goods/getGoodsPic/:goodsId"),{goodsId:goodsId}).get(success,error);
        };
        //根据goodsId获取商品评价
        this.getEvaluate=function (goodsId,pageIndex,pageSize,success,error) {
            return $resource(Base.stringFormat("/api/evaluate/getList/:goodsId/:pageIndex/:pageSize"),{goodsId:goodsId,pageIndex:pageIndex,pageSize:pageSize}).get(success,error);
        };
        //根据goodsId获取商品规格
        this.getGoodsWeightById=function (goodsId,success,error) {
            return $resource(Base.stringFormat("/api/goodsWeight/getListByGoodsId/:goodsId"),{goodsId:goodsId}).get(success,error);
        };
        /*--------------------------------------旧物------------------------*/
        //获取旧物列表信息
        this.getOldList = function (pageIndex,pageSize,oldParam,success,error) {
            return $resource(Base.stringFormat("/api/oldsRetrieve/getList/:pageIndex/:pageSize"),{pageIndex:pageIndex,pageSize:pageSize}).save(oldParam,success,error);
        };
        //根据goodsId获取商品信息
        this.getOldById=function (id,success,error) {
            return $resource(Base.stringFormat("/api/oldsRetrieve/getOldById/:id"),{id:id}).get(success,error);
        };
        //审核旧物
        this.checkOld=function (oldId,checkStatus,success,error) {
            return $resource(Base.stringFormat("/api/oldsRetrieve/checkStatus/:oldId/:checkStatus"),{oldId:oldId,checkStatus:checkStatus}).get(success,error);
        };
        //删除展示图片
        this.deleteOldIconUrl=function(id,success,error){
            return $resource(Base.stringFormat("/api/oldsRetrieve/updateIconUrl/:id"),{id:id}).get(success,error);
        };
        //修改交易状态
        this.updateDealStatus=function (oldId,dealStatus,success,error) {
            return $resource(Base.stringFormat("/api/oldsRetrieve/updateDealStatus/:oldId/:dealStatus"),{oldId:oldId,dealStatus:dealStatus}).get(success,error);
        };
        //添加商品
        this.addOld=function (old,success,error) {
            return $resource(Base.stringFormat("/api/oldsRetrieve/add")).save(old,success,error);
        };
        //修改旧物
        this.updateOld = function (old,success,error) {
            return $resource(Base.stringFormat("/api/oldsRetrieve/update"), null, {'save': {method: 'PUT'}}).save(old,success, error);
        };
        //旧物估价
        this.assessOld=function (old,success,error) {
            return $resource(Base.stringFormat("/api/oldsRetrieve/assessOld")).save(old,success,error);
        };
        //删除旧物
        this.deleteOld=function (oldId,success,error) {
            return $resource(Base.stringFormat("/api/oldsRetrieve/delete/:oldId"),{oldId:oldId}).delete(success,error);
        };

        //获取协议列表
        this.getAgreemeneList = function (success,error) {
            return $resource(Base.stringFormat("/api/agreement/getList")).get(success,error);
        };
        //获取协议详情
        this.getAgreemeneDetail = function (id,success,error) {
            return $resource(Base.stringFormat("/api/agreement/get/:id"),{id:id}).get(success,error);
        };
        //修改协议详情
        this.submitAgreement = function (agreement,success,error) {
            return $resource(Base.stringFormat("/api/agreement/update"), null, {'save': {method: 'PUT'}}).save(agreement,success, error);
        };

        //获取人员列表数据
        this.getUserList = function (pageIndex,pageSize,param,success,error) {
            return $resource(Base.stringFormat("/api/user/list/:pageIndex/:pageSize"),{pageIndex:pageIndex,pageSize:pageSize}).save(param,success,error);
        };
        //获取人员列表数据(最新消息)
        this.getUserListWithMsg = function (pageIndex,pageSize,param,success,error) {
            return $resource(Base.stringFormat("/api/user/listwithMsg/:pageIndex/:pageSize"),{pageIndex:pageIndex,pageSize:pageSize}).save(param,success,error);
        };
        //获取该用户与我的聊天记录
        this.getTalkRecordWithMe = function (userId,pageIndex,pageSize,success,error) {
            return $resource(Base.stringFormat("/api/message/talk/list/:userId/:pageIndex/:pageSize"),{userId:userId,pageIndex:pageIndex,pageSize:pageSize}).get(success,error);
        };
        //撤销聊天信息
        this.deleteTalkMsg = function (msgId,success,error) {
            return $resource(Base.stringFormat("/api/message/delete/:msgId"),{msgId:msgId}).delete(success,error);
        };
        //清空和用户的聊天信息
        this.clearTalkMsg = function (userId,success,error) {
            return $resource(Base.stringFormat("/api/message/clean/:userId"),{userId:userId}).delete(success,error);
        };
        //清空和用户的聊天信息
        this.mutClearTalkMsg = function (userIds,success,error) {
            return $resource(Base.stringFormat("/api/message/clean")).save(userIds,success,error);
        };

        //删除用户
        this.deleteUser = function (userIds,success,error) {
            return $resource(Base.stringFormat("/api/user/delete")).save(userIds,success,error);
        };
        //查询用户
        this.getUserDetail = function (userId,success,error) {
            return $resource(Base.stringFormat("/api/user/detail/:userId"),{userId:userId}).get(success,error);
        };
        //审核用户
        this.userCheckStatus = function (user,success,error) {
            return $resource(Base.stringFormat("/api/user/checkUser")).save(user,success,error);
        };
        this.updateUser=function(user,success,error){
            return $resource(Base.stringFormat("/dapi/user/update")).save(user,success,error);
        };
        this.getRoleById=function(userId,success,error){
            return $resource(Base.stringFormat("/api/user/getRole/:userId"),{userId:userId}).get(success,error);
        };

        //获取全部角色
        this.getRoleList = function (pageIndex,pageSize,param,success,error) {
            return $resource(Base.stringFormat("/api/role/list/:pageIndex/:pageSize"),{pageIndex:pageIndex,pageSize:pageSize}).save(param,success,error);
        };
        //获取全部角色
        this.getAllRoleList = function (success,error) {
            return $resource(Base.stringFormat("/api/role/alllist")).get(success,error);
        };
        //添加用户角色关系
        this.addUserRole = function (param,success,error) {
            return $resource(Base.stringFormat("/api/role/addUserRole")).save(param,success,error);
        };
        //添加角色
        /*this.addRoleSer = function (role,success,error) {
            return $resource(Base.stringFormat("/api/role/add")).save(role,success,error);
        };*/
        this.addRoleSer=function (role,success,error) {
            return $resource(Base.stringFormat("/api/role/add")).save(role,success,error);
        };
        //删除用户角色关系
        this.deleteUserRole = function (param,success,error) {
            return $resource(Base.stringFormat("/api/role/deleteUserRole")).save(param,success,error);
        };
        //删除角色
        this.deleteRole = function (code,success,error) {
            return $resource(Base.stringFormat("/api/role/delete/:code"),{code:code}).delete(success,error);
        };
        //根据角色id获取权限
        this.getPermListbyRoleCode = function (roleCode,success,error) {
            return $resource(Base.stringFormat("/api/permission/list/roleCode/:roleCode"),{roleCode:roleCode}).get(success,error);
        };
        //获取所有权限
        this.getAllPermList = function (success,error) {
            return $resource(Base.stringFormat("/api/permission/all/list")).get(success,error);
        };
        //给角色添加权限
        this.addPermToRole = function (roleCode,permId,success,error) {
            return $resource(Base.stringFormat("/api/permission/add/permtorole/:roleCode/:permId"),{roleCode:roleCode,permId:permId}).get(success,error);
        };
        //角色删除权限
        this.deletePermToRole = function (roleCode,permId,success,error) {
            return $resource(Base.stringFormat("/api/permission/delete/permtorole/:roleCode/:permId"),{roleCode:roleCode,permId:permId}).delete(success,error);
        };

        //获取公告信息列表
        this.getNoticeList = function (pageIndex,pageSize,param,success,error) {
            return $resource(Base.stringFormat("/api/notice/list/:pageIndex/:pageSize"),{pageIndex:pageIndex,pageSize:pageSize}).save(param,success,error);
        };
        //启用公告信息
        this.enableNotice = function (noticeId,success,error) {
            return $resource(Base.stringFormat("/api/notice/enable/:noticeId"),{noticeId:noticeId}).get(success,error);
        };
        //根据id获取公告信息
        this.getNoticeById = function (noticeId,success,error) {
            return $resource(Base.stringFormat("/api/notice/get/:noticeId"),{noticeId:noticeId}).get(success,error);
        };
        //修改公告信息
        this.updateNotice = function (notice,success,error) {
            return $resource(Base.stringFormat("/api/notice/update"), null, {'save': {method: 'PUT'}}).save(notice,success, error);
        };
        //添加公告信息
        this.addNotice = function (notice,success,error) {
            return $resource(Base.stringFormat("/api/notice/add")).save(notice,success,error);
        };
        //获取材质类型价格列表
        this.getGtypeList = function (success,error) {
            return $resource(Base.stringFormat("/api/dic/get/gtype")).get(success,error);
        };
        //启用或关闭
        this.enableGtype = function (id,ifUse,success,error) {
            return $resource(Base.stringFormat("/api/dic/enable/gtype/:id/:ifUse"),{id:id,ifUse:ifUse}).get(success,error);
        };
        //添加
        this.addGtype = function (gtype,success,error) {
            return $resource(Base.stringFormat("/api/dic/add/gtype")).save(gtype,success,error);
        };
        //修改
        this.updateGtype = function (gtype,success,error) {
            return $resource(Base.stringFormat("/api/dic/update/gtype"), null, {'save': {method: 'PUT'}}).save(gtype,success, error);
        };
        //获取订单列表
        this.getOrderList = function (pageIndex,pageSize,param,success,error) {
            return $resource(Base.stringFormat("/api/order/getList/:pageIndex/:pageSize"),{pageIndex:pageIndex,pageSize:pageSize}).save(param,success,error);
        };
        //根据id获取订单列表
        this.getOrderById = function (orderId,success,error) {
            return $resource(Base.stringFormat("/api/order/getOrder/:orderId"),{orderId:orderId}).get(success,error);
        };
        //修改配货状态
        this.updatePhStatus = function (goods,success,error) {
            return $resource(Base.stringFormat("/api/order/updatePhStatus"), null, {'save': {method: 'PUT'}}).save(goods,success, error);
        };
        //修改订单信息
        this.updateOrderInfo = function (order,success,error) {
            return $resource(Base.stringFormat("/api/order/update"), null, {'save': {method: 'PUT'}}).save(order,success, error);
        };
        //添加修改订单物流信息
        this.addExpressCode=function (order,success,error) {
            return $resource(Base.stringFormat("/api/order/addExpressCode")).save(order,success,error);
        };
        //获取优惠券
        this.getCouponList = function (pageIndex,pageSize,param,success,error) {
            return $resource(Base.stringFormat("/api/coupon/getList/:pageIndex/:pageSize"),{pageIndex:pageIndex,pageSize:pageSize}).save(param,success,error);
        };
        //获取优惠券
        this.getCouponById = function (couponId,success,error) {
            return $resource(Base.stringFormat("/api/coupon/get/:couponId"),{couponId:couponId}).get(success,error);
        };
        //发放优惠券
        this.sendCouponToUser = function (sendCouponUser,success,error) {
            return $resource(Base.stringFormat("/api/coupon/send/coupon")).save(sendCouponUser,success,error);
        };
        //添加优惠券
        this.submitCoupon = function (coupon,success,error) {
            return $resource(Base.stringFormat("/api/coupon/add")).save(coupon,success,error);
        };
        //一键更新单价
        this.updatePrice = function (gtype,success,error) {
            return $resource(Base.stringFormat("/api/gType/update/price"), null, {'save': {method: 'PUT'}}).save(gtype,success, error);
        };

        //按照商品类型进行统计分析
        this.analysisByGStyle = function (anParam,success,error) {
            return $resource(Base.stringFormat("/api/analysis/analysisByGStyle")).save(anParam,success,error);
        };
        //根据商品材质进行统计分析
        this.analysisByType = function (anParam,success,error) {
            return $resource(Base.stringFormat("/api/analysis/analysisByType")).save(anParam,success,error);
        };
        //获取分享列表
        this.getTranslateList = function (pageIndex,pageSize,success,error) {
            return $resource(Base.stringFormat("/api/translate/getList/:pageIndex/:pageSize"),{pageIndex:pageIndex,pageSize:pageSize}).get(success,error);
        };
        //获取用户角色
        this.getUserRoleList = function (userId,success,error) {
            return $resource(Base.stringFormat("/api/permission/getUserRoleList/:userId"),{userId:userId}).get(success,error);
        };
        //获取代理商信息列表
        this.getAgentList = function (success,error) {
            return $resource(Base.stringFormat("/dapi/agent/getList")).get(success,error);
        };
        //删除代理商信息
        this.deleteAgentById = function (agentId,success,error) {
            return $resource(Base.stringFormat("/api/agent/delete/:agentId"),{agentId:agentId}).delete(success,error);
        };
        //添加代理商
        this.addAgent = function (agent,success,error) {
            return $resource(Base.stringFormat("/api/agent/add")).save(agent,success,error);
        };
        //添加消息群发
        this.addMessageGroup = function(message,success,error){
            return $resource(Base.stringFormat("/api/messageGroup/add")).save(message,success,error);
        }
        //获取消息群发
        this.getMessageGroupList = function (pageIndex,pageSize,param,success,error) {
            return $resource(Base.stringFormat("/api/messageGroup/list/:pageIndex/:pageSize"),{pageIndex:pageIndex,pageSize:pageSize}).save(param,success,error);
        };
        //删除消息群发
        this.deleteMessagegroup = function(messageGroupId,success,error){
            return $resource(Base.stringFormat("/api/messageGroup/delete/:messageGroupId"),{messageGroupId:messageGroupId}).delete(success,error);
        }
        //修改消息群发
        this.updateMessageGroup = function(messageGroup,success,error){
            return $resource(Base.stringFormat("/api/messageGroup/update")).save(messageGroup,success,error);
        }
        //获取消息群发明细
        this.getMessageGroupId = function(messageGroupId,success,error){
            return $resource(Base.stringFormat("/api/messageGroup/getMessageGroupUser/:messageGroupId"),{messageGroupId:messageGroupId}).get(success,error);
        }
        //修改代理商
        this.updateAgent = function (agent,success,error) {
            return $resource(Base.stringFormat("/api/agent/update")).save(agent,success,error);
        };

        /*-------------------------------App首页轮播图片-------------------------------*/
        //获取App首页轮播图片列表
        this.getAppPicList = function (success,error) {
            return $resource(Base.stringFormat("/dapi/appPic/getList")).get(success,error);
        };
        //删除App首页轮播图片
        this.deleteAppPicById = function (appPicId,success,error) {
            return $resource(Base.stringFormat("/api/appPic/delete/:appPicId"),{appPicId:appPicId}).delete(success,error);
        };
        //添加App首页轮播图片
        this.addAppPic = function (agent,success,error) {
            return $resource(Base.stringFormat("/api/appPic/add")).save(agent,success,error);
        };
        //修改App首页轮播图片
        this.updateAppPic = function (appPic,success,error) {
            return $resource(Base.stringFormat("/api/appPic/update")).save(appPic,success,error);
        };
        //获取材质一级列表
        this.getGTypeOneList = function (success,error) {
            return $resource(Base.stringFormat("/api/gTypeOne/getGoodNav")).get(success,error);
        };
        //获取材质一二级列表
        this.getGTypeOneTwoList = function (success,error) {
            return $resource(Base.stringFormat("/api/gTypeOne/getGoodNavTwo")).get(success,error);
        };
        //根据id查询一级类型
        this.getGTypeOneById = function (id,success,error) {
            return $resource(Base.stringFormat("/api/gTypeOne/get/:id"),{id:id}).get(success,error);
        };
        //修改一级类型
        this.updateGTypeOne = function (gtypeOne,success,error) {
            return $resource(Base.stringFormat("/api/gTypeOne/update"), null, {'save': {method: 'PUT'}}).save(gtypeOne,success, error);
        };
        //添加一级类型
        this.addGTypeOne = function (gtypeOne,success,error) {
            return $resource(Base.stringFormat("/api/gTypeOne/add")).save(gtypeOne,success,error);
        };
        //删除一级类型
        this.deleteTypeOneById = function (id,success,error) {
            return $resource(Base.stringFormat("/api/gTypeOne/delete/:id"),{id:id}).delete(success,error);
        };

        //修改样式
        this.updateGStyle = function (gstyle,success,error) {
            return $resource(Base.stringFormat("/api/gStyle/update"), null, {'save': {method: 'PUT'}}).save(gstyle,success, error);
        };
        //添加样式
        this.addGStyle = function (gstyle,success,error) {
            return $resource(Base.stringFormat("/api/gStyle/add")).save(gstyle,success,error);
        };
        //删除样式
        this.deleteGStyleById = function (id,success,error) {
            return $resource(Base.stringFormat("/api/gStyle/delete/:id"),{id:id}).delete(success,error);
        };
        //修改品型
        this.updatePX = function (pXing,success,error) {
            return $resource(Base.stringFormat("/api/gTypeOne/updatePX"), null, {'save': {method: 'PUT'}}).save(pXing,success, error);
        };
        //添加品型
        this.addPX = function (pXing,success,error) {
            return $resource(Base.stringFormat("/api/gTypeOne/addPX")).save(pXing,success,error);
        };
        //删除品型
        this.deletePX = function (id,success,error) {
            return $resource(Base.stringFormat("/api/gTypeOne/deletePX/:id"),{id:id}).delete(success,error);
        };
        //根据style查询品型
        this.getPxByStyle = function (pId,success,error) {
            return $resource(Base.stringFormat("/api/gTypeOne/getPxByStyle/:pId"),{pId:pId}).get(success,error);
        };
        //获取三级列表菜单
        this.getGoogsTypeList = function(success,error){
            return $resource("/dapi/mGoodType/getGoodNav").get(success,error);
        };
       /* //获取当日价格
        this.getTodayPrice = function(success,error){
            return $resource("/api/gType/todayPrice").get(success,error);
        };*/
        //复制产品
        this.copyGoodsByIds = function (ids,success,error) {
            return $resource(Base.stringFormat("/api/goods/copyGoodsByIds")).save(ids,success,error);
        };

        //批量上架产品
        this.grounding = function (ids,success,error) {
            return $resource(Base.stringFormat("/api/goods/groundingByIds")).save(ids,success,error);
        };
        //批量下架产品
        this.undercarriage = function (ids,success,error) {
            return $resource(Base.stringFormat("/api/goods/undercarriageByIds")).save(ids,success,error);
        };

        //批量下架产品
        this.review = function (ids,success,error) {
            return $resource(Base.stringFormat("/api/goods/reviewByIds")).save(ids,success,error);
        };
    }]);
});